package indzcraft.loader;

public class ItemEquipped {
	
	private Item item;
	private Reforge reforge = null;
	public Gem[] gem = new Gem[3];
	private Enchant enchant = null;

	public Item getItem() {
		return item;
	}

	public void setItem(Item item) {
		this.item = item;
	}
	public void removeReforge(){
		this.reforge = null;
	}
	public Reforge getReforge() {
		if(reforge == null)
			reforge = new Reforge();
		return reforge;
	}

	public void setReforge(Reforge reforge) {
		this.reforge = reforge;
	}

	public Enchant getEnchant() {
		return enchant;
	}

	public void setEnchant(Enchant enchant) {
		this.enchant = enchant;
	}
		
	public Gem getGem(int slot){
		return gem[slot];
	}
	
	public void setGem(int slot, Gem gem){
		this.gem[slot] = gem;
	}
	
	public int getReforgedCrit() {
		int value = 0;
		if(reforge != null){
			if(reforge.getFrom().equals("Crit Rating")){
				value = getReforgeValue();
			}
			else if(reforge.getTo().equals("Crit Rating")){
				value -= getReforgeValue();
			}
		}
		return item.getCrit()-value;
	}
	public int getReforgedHaste() {
		int value = 0;
		if(reforge != null){
			if(reforge.getFrom().equals("Haste Rating")){
				value = getReforgeValue();
			}
			else if(reforge.getTo().equals("Haste Rating")){
				value -= getReforgeValue();
			}
		}
		return item.getHaste()-value;
	}
	public int getReforgedHit() {
		int value = 0;
		if(reforge != null){
			if(reforge.getFrom().equals("Hit Rating")){
				value = getReforgeValue();
			}
			else if(reforge.getTo().equals("Hit Rating")){
				value -= getReforgeValue();
			}
		}
		return item.getHit()-value;
	}
	public int getReforgedExp() {
		int value = 0;
		if(reforge != null){
			if(reforge.getFrom().equals("Expertise Rating")){
				value = getReforgeValue();
			}
			else if(reforge.getTo().equals("Expertise Rating")){
				value -= getReforgeValue();
			}
		}
		return item.getExp()-value;
	}
	public int getReforgedMastery() {
		int value = 0;
		if(reforge != null){
			if(reforge.getFrom().equals("Mastery Rating")){
				value = getReforgeValue();
			}
			else if(reforge.getTo().equals("Mastery Rating")){
				value -= getReforgeValue();
			}
		}
		return item.getMastery()-value;
	}
	
	public int getReforgeValue(){
		int value = 0;
		if(reforge != null){
			if(reforge.getFrom().equals("Hit Rating")){
				value = (int) Math.floor(item.getHit()*0.4);
			}
			else if(reforge.getFrom().equals("Crit Rating")){
				value = (int) Math.floor(item.getCrit()*0.4);
			}
			else if(reforge.getFrom().equals("Haste Rating")){
				value = (int) Math.floor(item.getHaste()*0.4);
			}
			else if(reforge.getFrom().equals("Mastery Rating")){
				value = (int) Math.floor(item.getMastery()*0.4);
			}
			else if(reforge.getFrom().equals("Expertise Rating")){
				value = (int) Math.floor(item.getExp()*0.4);
			}
		}
		return value;
	}
}
